<script setup lang="ts">
import { ref, onMounted } from 'vue'

// 统计数据
const stats = ref([
  { label: '总员工数', value: '1,234', icon: '👥', color: '#3b82f6' },
  { label: '总学员数', value: '5,678', icon: '🎓', color: '#10b981' },
  { label: '总班级数', value: '89', icon: '🏫', color: '#f59e0b' },
  { label: '总部门数', value: '12', icon: '🏢', color: '#8b5cf6' }
])

// 最近活动
const recentActivities = ref([
  { type: '新增', content: '张三 加入了 技术部', time: '2分钟前', color: '#10b981' },
  { type: '更新', content: '李四 更新了个人信息', time: '5分钟前', color: '#3b82f6' },
  { type: '毕业', content: '王五 完成了培训课程', time: '10分钟前', color: '#f59e0b' },
  { type: '创建', content: '新班级 "AI进阶班" 已创建', time: '15分钟前', color: '#8b5cf6' }
])

// 快速操作
const quickActions = ref([
  { title: '添加员工', icon: '👤', path: '/emp', color: '#3b82f6' },
  { title: '创建班级', icon: '🏫', path: '/clazz', color: '#10b981' },
  { title: '学员管理', icon: '🎓', path: '/stu', color: '#f59e0b' },
  { title: '部门管理', icon: '🏢', path: '/dept', color: '#8b5cf6' }
])
</script>

<template>
  <div class="dashboard-container">
    <!-- 欢迎区域 -->
    <div class="welcome-section">
      <div class="welcome-content">
        <div class="welcome-text">
          <h1>欢迎使用金蛛AI教学管理系统</h1>
          <p>高效管理员工、学员、班级和部门信息，助力企业数字化转型</p>
        </div>
        <div class="welcome-illustration">
          <svg viewBox="0 0 200 200" class="ai-illustration">
            <!-- 背景圆圈 -->
            <circle cx="100" cy="100" r="80" fill="url(#gradient1)" opacity="0.1"/>
            <circle cx="100" cy="100" r="60" fill="url(#gradient2)" opacity="0.2"/>
            
            <!-- 中心AI图标 -->
            <g transform="translate(100, 100)">
              <!-- 大脑图标 -->
              <path d="M-20,-15 Q-25,-25 -20,-35 Q-15,-45 -5,-45 Q5,-45 10,-35 Q15,-25 10,-15 Q5,-5 -5,-5 Q-15,-5 -20,-15 Z" 
                    fill="url(#gradient3)" opacity="0.8"/>
              <path d="M10,-15 Q15,-25 10,-35 Q5,-45 -5,-45 Q-15,-45 -20,-35 Q-25,-25 -20,-15 Q-15,-5 -5,-5 Q5,-5 10,-15 Z" 
                    fill="url(#gradient4)" opacity="0.6"/>
              
              <!-- 连接线 -->
              <line x1="-15" y1="-10" x2="15" y2="-10" stroke="#3b82f6" stroke-width="2" opacity="0.6"/>
              <line x1="-15" y1="0" x2="15" y2="0" stroke="#10b981" stroke-width="2" opacity="0.6"/>
              <line x1="-15" y1="10" x2="15" y2="10" stroke="#f59e0b" stroke-width="2" opacity="0.6"/>
              
              <!-- 数据点 -->
              <circle cx="-25" cy="-25" r="3" fill="#3b82f6" opacity="0.8"/>
              <circle cx="25" cy="-25" r="3" fill="#10b981" opacity="0.8"/>
              <circle cx="-25" cy="25" r="3" fill="#f59e0b" opacity="0.8"/>
              <circle cx="25" cy="25" r="3" fill="#8b5cf6" opacity="0.8"/>
            </g>
            
            <!-- 渐变定义 -->
            <defs>
              <linearGradient id="gradient1" x1="0%" y1="0%" x2="100%" y2="100%">
                <stop offset="0%" style="stop-color:#3b82f6;stop-opacity:1" />
                <stop offset="100%" style="stop-color:#1d4ed8;stop-opacity:1" />
              </linearGradient>
              <linearGradient id="gradient2" x1="0%" y1="0%" x2="100%" y2="100%">
                <stop offset="0%" style="stop-color:#10b981;stop-opacity:1" />
                <stop offset="100%" style="stop-color:#059669;stop-opacity:1" />
              </linearGradient>
              <linearGradient id="gradient3" x1="0%" y1="0%" x2="100%" y2="100%">
                <stop offset="0%" style="stop-color:#8b5cf6;stop-opacity:1" />
                <stop offset="100%" style="stop-color:#7c3aed;stop-opacity:1" />
              </linearGradient>
              <linearGradient id="gradient4" x1="0%" y1="0%" x2="100%" y2="100%">
                <stop offset="0%" style="stop-color:#f59e0b;stop-opacity:1" />
                <stop offset="100%" style="stop-color:#d97706;stop-opacity:1" />
              </linearGradient>
            </defs>
          </svg>
        </div>
      </div>
    </div>

    <!-- 统计卡片 -->
    <div class="stats-section">
      <div class="stats-grid">
        <div 
          v-for="stat in stats" 
          :key="stat.label" 
          class="stat-card"
          :style="{ '--card-color': stat.color }"
        >
          <div class="stat-icon">{{ stat.icon }}</div>
          <div class="stat-content">
            <div class="stat-value">{{ stat.value }}</div>
            <div class="stat-label">{{ stat.label }}</div>
          </div>
        </div>
      </div>
    </div>

    <!-- 快速操作 -->
    <div class="quick-actions-section">
      <h2>快速操作</h2>
      <div class="actions-grid">
        <div 
          v-for="action in quickActions" 
          :key="action.title" 
          class="action-card"
          :style="{ '--action-color': action.color }"
        >
          <div class="action-icon">{{ action.icon }}</div>
          <div class="action-title">{{ action.title }}</div>
        </div>
      </div>
    </div>

    <!-- 最近活动 -->
    <div class="recent-activities-section">
      <h2>最近活动</h2>
      <div class="activities-list">
        <div 
          v-for="activity in recentActivities" 
          :key="activity.content" 
          class="activity-item"
        >
          <div class="activity-type" :style="{ backgroundColor: activity.color }">
            {{ activity.type }}
          </div>
          <div class="activity-content">
            <div class="activity-text">{{ activity.content }}</div>
            <div class="activity-time">{{ activity.time }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>
.dashboard-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0;
}

/* 欢迎区域 */
.welcome-section {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 20px;
  padding: 40px;
  margin-bottom: 32px;
  color: white;
  position: relative;
  overflow: hidden;
}

.welcome-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="white" opacity="0.1"/><circle cx="75" cy="75" r="1" fill="white" opacity="0.1"/><circle cx="50" cy="10" r="0.5" fill="white" opacity="0.1"/><circle cx="10" cy="60" r="0.5" fill="white" opacity="0.1"/><circle cx="90" cy="40" r="0.5" fill="white" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
  opacity: 0.3;
}

.welcome-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 2;
}

.welcome-text h1 {
  font-size: 32px;
  font-weight: 700;
  margin: 0 0 12px 0;
  letter-spacing: -0.5px;
}

.welcome-text p {
  font-size: 18px;
  margin: 0;
  opacity: 0.9;
  line-height: 1.6;
}

.welcome-illustration {
  flex-shrink: 0;
}

.ai-illustration {
  width: 200px;
  height: 200px;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.2));
}

/* 统计卡片 */
.stats-section {
  margin-bottom: 32px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 24px;
}

.stat-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--card-color);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.stat-icon {
  font-size: 32px;
  width: 60px;
  height: 60px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--card-color), var(--card-color)dd);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.stat-content {
  flex: 1;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 14px;
  color: #64748b;
  font-weight: 500;
}

/* 快速操作 */
.quick-actions-section {
  margin-bottom: 32px;
}

.quick-actions-section h2 {
  font-size: 24px;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 20px 0;
}

.actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.action-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  border: 1px solid #e2e8f0;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.action-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--action-color)10, var(--action-color)05);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.action-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.action-card:hover::before {
  opacity: 1;
}

.action-icon {
  font-size: 32px;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}

.action-title {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
  position: relative;
  z-index: 1;
}

/* 最近活动 */
.recent-activities-section h2 {
  font-size: 24px;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 20px 0;
}

.activities-list {
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  border: 1px solid #e2e8f0;
  overflow: hidden;
}

.activity-item {
  display: flex;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid #f1f5f9;
  transition: background-color 0.3s ease;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-item:hover {
  background-color: #f8fafc;
}

.activity-type {
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  margin-right: 16px;
  flex-shrink: 0;
}

.activity-content {
  flex: 1;
}

.activity-text {
  font-size: 14px;
  color: #1e293b;
  margin-bottom: 4px;
  font-weight: 500;
}

.activity-time {
  font-size: 12px;
  color: #64748b;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .welcome-content {
    flex-direction: column;
    text-align: center;
    gap: 24px;
  }
  
  .welcome-text h1 {
    font-size: 24px;
  }
  
  .welcome-text p {
    font-size: 16px;
  }
  
  .ai-illustration {
    width: 150px;
    height: 150px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .actions-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .welcome-section {
    padding: 24px;
  }
  
  .actions-grid {
    grid-template-columns: 1fr;
  }
  
  .stat-card {
    padding: 20px;
  }
  
  .action-card {
    padding: 20px;
  }
}

/* 动画效果 */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.welcome-section,
.stats-section,
.quick-actions-section,
.recent-activities-section {
  animation: fadeInUp 0.6s ease-out;
}

.stats-section {
  animation-delay: 0.1s;
}

.quick-actions-section {
  animation-delay: 0.2s;
}

.recent-activities-section {
  animation-delay: 0.3s;
}
</style>